<template>
  <view class="container">
    <view class="head">
    
    </view>
    <!-- 使用选择时间组件 -->
    <itmister-date-picker
      ref="dateEl"
      @dateConfirm="dateConfirm"
    ></itmister-date-picker>
    <!-- 筛选弹窗 -->
    <uni-popup
      ref="popup"
      class="popup1"
      type="bottom"
      background-color="#fff"
      @change="change"
    >
      <view
        class="popup-content"
        :class="{ 'popup-height': type === 'left' || type === 'right' }"
      >
        <view class="pop_title">选择筛选项</view>
        <view class="title2">收支类型</view>
        <view class="tag_box">
          <uni-tag
            class="tag_item"
            :class="type1 == 'success' ? 'active' : ''"
            :type="type1"
            text="全部"
            :inverted="true"
            @click="setType1('week')"
          />
          <uni-tag
            class="tag_item"
            :type="type2"
            :class="type2 == 'success' ? 'active' : ''"
            text="支出"
            :inverted="true"
            @click="setType2('mouth')"
          />
          <uni-tag
            class="tag_item"
            :type="type3"
            text="收入"
            :class="type3 == 'success' ? 'active' : ''"
            :inverted="true"
            @click="setType3('anytime')"
          />
        </view>
        <view class="title2">交易类型</view>
        <view class="tag_box">
          <uni-tag
            v-for="item in tagList"
            :key="item.index"
            class="tag_item"
            :class="!item.isAble && item.type == 'success' ? 'active' : ''"
            :type="item.type"
            :text="item.name"
            :inverted="true"
            :disabled="item.isAble"
            @click="setTagListType(item.name)"
          />
        </view>
      </view>
      <view class="btn_box">
        <view class="btn4 btn5" @tap="close()">取消</view>
        <view class="btn4" @tap="close()">确定</view>
      </view>
    </uni-popup>
  </view>
</template>

<script>
import itmisterDatePicker from "@/components/itmister-date-picker/itmister-date-picker.nvue";
import axios from "axios";
export default {
  components: { itmisterDatePicker },
  data() {
    return {
      title: "选择日期",
      date: " 2024年4月",
      type1: "success",
      type2: "default",
      type3: "default",
     
      billList: [
        {
          name: "包子铺",
          time: "4月25日  08:06",
          money: "-6.00",
          avatar:
            "https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png",
        },
        {
          name: "包子铺",
          time: "4月25日  08:06",
          money: "-6.00",
          avatar:
            "https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png",
        },
        {
          name: "扫二维码支付款",
          time: "4月25日  08:06",
          money: "-6.00",
          avatar:
            "https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png",
        },
        {
          name: "转帐-转给小米",
          time: "4月25日  08:06",
          money: "-6.00",
          avatar:
            "https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png",
        },
        {
          name: "转账-来自Lucas",
          time: "4月25日  08:06",
          money: "+80.00",
          type: "add",
          avatar:
            "https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png",
        },
        {
          name: "包子铺",
          time: "4月25日  08:06",
          money: "-8.00",
          avatar:
            "https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png",
        },
        {
          name: "转账-来自Lucas",
          time: "4月25日  08:06",
          money: "+80.00",
          type: "add",
          avatar:
            "https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png",
        },
        {
          name: "转账-来自Lucas",
          time: "4月25日  08:06",
          money: "+80.00",
          type: "add",
          avatar:
            "https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png",
        },
        {
          name: "包子铺",
          time: "4月25日  08:06",
          money: "-8.00",
          avatar:
            "https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png",
        },
        {
          name: "花小猪打车",
          time: "4月25日  08:06",
          money: "-6.00",
          avatar:
            "https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png",
        },
      ],
      tagList: [
        {
          type: "success",
          name: "全部",
          isAble: false,
        },
        {
          type: "default",
          name: "红包",
          isAble: false,
        },
        {
          type: "default",
          name: "转账",
          isAble: false,
        },
        {
          type: "default",
          name: "群收款",
          isAble: false,
        },
        {
          type: "default",
          name: "二维码收款",
          isAble: false,
        },
        {
          type: "default",
          name: "商户消费",
          isAble: false,
        },
        {
          type: "default",
          name: "充值提现",
          isAble: false,
        },
        {
          type: "default",
          name: "信用卡还款",
          isAble: false,
        },
        {
          type: "default",
          name: "有退款",
          isAble: false,
        },
      ],
      page: 0,
      status: "more",
      type: "bottom",
      token: null,
    };
  },
  onReachBottom() {
  },
  onPullDownRefresh() {
  },
  onload() {
  },
  created() {
  },
  methods: {
    // 打开选择器
    selectDate() {
      this.$refs.dateEl.show();
    },
    // 选中日期
    dateConfirm(date) {
      this.date = date;
    },
    setTagListType(name, type) {
      let types = ["default", "success"];
      this.tagList.forEach((element) => {
        if (element.name == name) {
          let index = types.indexOf(element.type);
          types.indexOf(element.type);
          types.splice(index, 1);
          element.type = types.join(",");
        } else {
          element.type = "default";
        }
      });
    },
    setType1(type) {
      let types = ["default", "success"];
      let index = types.indexOf(this.type1);
      types.splice(index, 1);
      this.type1 = types.join(",");
      this.type2 = "default";
      this.type3 = "default";
      this.tagList.forEach((item) => {
        item.isAble = false;
      });
    },
    setType2(type) {
      let types = ["default", "success"];
      let index = types.indexOf(this.type2);
      types.splice(index, 1);
      this.type2 = types.join(",");
      this.type1 = "default";
      this.type3 = "default";
      this.tagList.forEach((item) => {
        if (
          item.name == "充值提现" ||
          item.name == "信用卡还款" ||
          item.name == "有退款"
        ) {
          item.isAble = true;
        } else {
          item.isAble = false;
        }
      });
    },
    setType3(type) {
      let types = ["default", "success"];
      let index = types.indexOf(this.type3);
      types.splice(index, 1);
      this.type3 = types.join(",");
      this.type2 = "default";
      this.type1 = "default";
      this.tagList.forEach((item) => {
        if (
          item.name == "充值提现" ||
          item.name == "信用卡还款" ||
          item.name == "商户消费"
        ) {
          item.isAble = true;
        } else {
          item.isAble = false;
        }
      });
    },
    change(e) {
      console.log("当前模式：" + e.type + ",状态：" + e.show);
    },
    close() {
      this.$refs.popup.close();
    },
    // 全部筛选1
    allSelect() {
      this.$refs.popup.open("bottom");
    },
  
    async getList() {
      await this.getToken();
      // 准备要发送的数据，这里假设 token 存储在名为 token 的变量中
      // const data = {
      //   token: this.token,
      // };
      // 设置 get 请求的 URL
      // const url = `http://154.19.70.73/api/wechat/billList?token=${this.token}`;
      // // 发送 get 请求
      // axios
      //   .get(url)
      //   .then(function (response) {
      //     // 请求成功时的处理
      //     this.billList = response.data;
      //     console.log("服务器返回的数据：", response.data);
      //   })
      //   .catch(function (error) {
      //     // 请求失败时的处理
      //     console.error("请求失败：", error);
      //   });
    },
    toQuestion() {
      uni.navigateTo({
        url: "/pages/down_bill/choose_type",
      });
    },
  },
};
</script>

<style scoped lang="scss">
.btn_box {
  width: 90%;
  margin: 30px auto;
  margin-bottom: 50px;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 40px;
  .btn5 {
    background-color: #f2f2f2 !important;
    color: #000 !important;
    font-size: 16px;
  }
  .btn4 {
    width: 100px;
    font-size: 16px;
    height: 40px;
    line-height: 40px;
    text-align: center;
    color: #fff;
    margin: 0 10px;
    font-size: 18px;
    background-color: #05c160;
    border-radius: 5px;
  }
}

.active {
  background-color: #e4f8ef !important;
  border: 1px solid #4ec787 !important;
  color: #4ec787 !important;
  height: 27px !important;
  line-height: 27px !important;
}
.tag_box {
  margin-left: 10px;
  display: grid; /* 使用网格布局 */
  grid-template-columns: repeat(3, 1fr); /* 创建3列，每列宽度平分 */
  grid-gap: 10px; /* 设置网格间距 */
  .tag_item {
    // padding: 9px 25px;
    text-align: center;
    line-height: 28px;
    height: 28px;
    border: none;
    color: #000;
    border-radius: 5px;
    background-color: #f7f7f7;
    font-weight: 400;
    font-size: 14px;
  }
}

.popup-content {
  padding: 20px;
  .popup-content {
    align-items: center;
    justify-content: center;
  }
  .title2 {
    font-size: 14px;
    color: #999;
    margin: 20px 0 15px 0;
  }
  .pop_title {
    font-size: 16px;
    font-weight: 500;
    color: #000;
  }
}
.container {
  font-family: "PingFang SC", sans-serif !important;
  line-height: 24px;
  /deep/ .uni-list-chat__content-title {
    font-weight: 400;
    font-size: 18px;
  }
  .head {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
  }
  .top {
    height: 50px;
    line-height: 50px;
    text-align: center;
    position: relative;
    .title {
      font-size: 16px;
      font-weight: 400;
      background-color: #efefef;
      width: 100vw;
    }
    .to_question {
      position: absolute;
      right: 20px;
      top: 0;
    }
  }
  .search_box {
    background-color: #efefef;
    width: 100vw;
    border-top: 1px solid #e0e3ea;
    .search_item1 {
      padding: 0 20px;
      display: flex;
      height: 60px;
      justify-content: space-between;
      align-items: center;
      .btn1 {
        width: 100px;
        height: 35px;
        line-height: 35px;
        color: #000;
        background-color: #e3e3e3;
        border-radius: 30px;
        font-weight: 400;
        text-align: center;
        display: flex;
        justify-content: center;
        align-items: baseline;
        .triangle {
          margin-left: 5px;
          width: 0;
          height: 0;
          border-left: 5px solid transparent;
          border-right: 5px solid transparent;
          border-top: 7px solid #737373; /* 可以改变颜色 */
        }
      }
      .total {
        display: flex;
        justify-content: center;
        align-items: center;
        color: #737373;
        font-size: 14px;
      }
    }
    .search_item2 {
      height: 5%;
      line-height: 50px;
      border-top: 1px solid #e0e3ea;
      display: flex;
      justify-content: space-between;
      align-items: baseline;
      padding: 0 20px;
      .time {
        color: #000;
        font-weight: 400;
      }
      .get_total {
        color: #737373;
        font-size: 14px;
      }
    }
  }
  .chat-custom-right {
    flex: 1;
    /* #ifndef APP-NVUE */
    display: flex;
    /* #endif */
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-end;
  }

  .chat-custom-text {
    font-weight: 600 !important;
    font-size: 18px !important;
    color: #000;
  }
  .add {
    color: #ffd658 !important;
  }
  .list_box {
    margin-top: 112px;
  }
}
</style>
